//    Copyright (C) Kherty.  All rights reserved.
using System;

namespace OpenLS.Spreadsheet
{
    class CellsRangeOperations
    {
        public static CellsRange GetSlice(CellsRange This, NavigationDirection direction)
        {
            switch(direction)
            {
                case  NavigationDirection.Left:
                    return CellsRange.Create(This.Worksheet, new RangeAddress(new CellAddress(This.Row, This.Column),new CellAddress(This.Row + This.RowSpan - 1, This.Column)));
                case NavigationDirection.Right:
                    return CellsRange.Create(This.Worksheet, new RangeAddress(new CellAddress(This.Row, This.Column + This.ColumnSpan - 1), new CellAddress(This.Row + This.RowSpan - 1, This.Column + This.ColumnSpan - 1)));
                    case NavigationDirection.Up:
                    return CellsRange.Create(This.Worksheet, new RangeAddress(new CellAddress(This.Row, This.Column), new CellAddress(This.Row, This.Column + This.ColumnSpan - 1)));
                    case NavigationDirection.Down:
                    return CellsRange.Create(This.Worksheet, new RangeAddress(new CellAddress(This.Row + This.RowSpan - 1, This.Column), new CellAddress(This.Row + This.RowSpan - 1, This.Column + This.ColumnSpan - 1)));
                    default: throw new NotSupportedException();
            }
        }
        public static NavigationDirection GetOpposite (NavigationDirection dir)
        {
            switch (dir)
            {
                    case NavigationDirection.Down:return NavigationDirection.Up;
                    case NavigationDirection.Left:return NavigationDirection.Right;
                    case NavigationDirection.Right:return NavigationDirection.Left;
                    case NavigationDirection.Up: return NavigationDirection.Down;
                default: throw new NotSupportedException();
            }
        }
 
    }
}
